<template>
  <div class="search">
    <div class="span">
      <div>
        <van-nav-bar title="搜索" left-text="返回" left-arrow @click-left="onClickLeft" />
      </div>
    </div>
    <div class="sear">
      <input type="text" v-model="searchkey" placeholder="搜索商家，商品名称" class="input">
      <span @click="search ">搜索</span>
    </div>
    <div class="history">
      <p>历史搜索</p>
    </div>
    <div class="history-search">
      {{searchkey}}
    </div>
    <div class="find">
      <p>搜索发现</p>
    </div>
    <div class="shopping">
      <div class="main" v-for='(item,index) in data' :key="index">
        <div class="count" @click='xiangqing(item)'>
          <div class="count-left">
            <div class="img">
              <img :src="item.picUrl" alt="">
            </div>
          </div>
          <div class="count-right">
            <div class="title">
              <h3>{{item.name}}</h3>
            </div>
            <div class="xing-yueshou"><span style="color:red">⭐ 4.3</span>&nbsp;&nbsp;<span>{{item.monthSalesTip}}</span></div>
            <div class="qisong">
              <span>{{item.minPriceTip}}</span>
              <span>远距离{{item.shippingFeeTip}}</span>
              <span>{{item.averagePriceTip}}</span>
            </div>

            <div class="evaluate">
              <div class="evn">“扬州炒饭真好吃”</div>
              <div class="evn">海淀区北京菜畅销第2</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { search_list } from '../axios/api';
import { Toast } from 'vant';

export default {
  data() {
    return {
      data: [],
      searchkey: '',
    }
  },
  methods: {
    xiangqing(item) {
      this.$router.push('/myparticulars/' + item.mtWmPoiId)
    },
    onClickLeft() {
      this.$router.go(-1)
    },
    search() {
      search_list({ searchkey: this.searchkey }).then(
        response => {
          // if (response.data.list == '') {
          //   Toast.fail('没有找到相关店铺')
          // }
          if (response.data.code == 200) {
            this.data = response.data.list
            Toast.clear();
            Toast('为你找到以下店铺')
          }
        }
      )
    }

  }

}
</script>
<style scoped lang='scss'>
.shopping {
  width: 100%;
  height: 100%;
  //   background-color: aqua;
  margin-top: 15px;
  margin-bottom: 50px;

  .main {
    margin-bottom: 10px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .count {
      width: 94%;
      height: 140px;
      //   background-color: pink;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .count-left {
        width: 30%;
        height: 100%;
        // background-color: red;
        display: flex;
        justify-content: center;
        align-items: center;
        .img {
          width: 80%;
          height: 80%;
          img {
            width: 100%;
            height: 100%;
          }
        }
      }
      .count-right {
        flex: 1;
        height: 100%;
        // background-color: rgba(255, 166, 0, 0.173);
        .xing-yueshou {
          margin: 8px;
          span {
            color: gray;
            font-size: 14px;
          }
        }
        .qisong {
          width: 100%;
          height: 24px;
          //   background-color: rgba(255, 0, 0, 0.185);
          display: flex;
          justify-content: space-around;
          align-items: center;
          span {
            color: gray;
            font-size: 14px;
          }
        }
        .evaluate {
          width: 100%;
          height: 30px;
          margin-top: 6px;
          //   background-color: rgba(255, 0, 0, 0.207);
          display: flex;
          align-items: center;
          .evn {
            width: 120px;
            margin-left: 10px;
            height: 20px;
            background-color: #ffe6b5;
            border-radius: 10px;
            color: #ff5000;
            font-size: 12px;
            text-align: center;
            line-height: 20px;
          }
        }
      }
    }
  }
}
.search {
  padding: 10px;
  display: flex;
  flex-direction: column;
  /* justify-content: space-between; */
}
.finds {
  display: flex;
  /*   justify-content: space-; */
  flex-wrap: wrap;
}
.finds .find-s {
  height: 40px;
  /* width: 23%; */
  margin-bottom: 10px;

  background-color: rgb(245, 241, 241);
  border-radius: 15px;
  text-align: center;
  line-height: 40px;
  margin-right: 10px;
  padding: 0 10px;
}
.history-search {
  height: 40px;
  width: 60%;
  background-color: rgb(245, 241, 241);
  border-radius: 15px;
  text-align: center;
  line-height: 40px;
}
.history {
  display: flex;
}
.history p {
  font-size: 18px;
  font-weight: 700;
  margin: 20px 0;
}
.find p {
  font-size: 18px;
  font-weight: 700;
  margin: 20px 0;
}
.input {
  border: 1px solid gainsboro;
  width: 80%;
  margin-top: 30px;
  height: 40px;
  padding-left: 30px;
  box-sizing: border-box;
  border-radius: 15px;
}

.search span {
  font-size: 20px;
  color: #0074d972;
}
.search span:nth-child(1) {
  font-size: 20px;
}
.search span:nth-child(2) {
  margin-left: 10px;
}
.search .close {
  background-color: #0074d972;
  /*  margin-top: 20px; */
  width: 80px;
  height: 30px;
  display: flex;
  justify-content: space-between;
  padding: 0 10px 0 10px;
  color: white;
  border-radius: 15px;
  float: right;
  margin-left: 180px;
  /*        margin-top: 2px; */
}

.search .close .left {
  font-size: 20px;
  margin-bottom: 70px;
}

.search .close .cirl {
  border: 2px solid white;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  text-align: center;
  line-height: 25px;
}
</style>